package com.example.algorithm.insertionsort;

import com.example.algorithm.util.ArrayGenerator;
import com.example.algorithm.util.SortingHelper;
import com.example.mergesort.MergeSort;
import org.junit.Test;

import java.util.Arrays;

public class InsertionSortTest {

    @Test
    public void test1() {
        int[] dataSize = {10000, 100000};
        for (int n : dataSize) {
            System.out.println("Random Array:");
            Integer[] arr = ArrayGenerator.generateRandomArray(n, n);
            Integer[] arr2 = Arrays.copyOf(arr, arr.length);
            SortingHelper.sortTest("InsertionSort", arr);
            SortingHelper.sortTest("InsertionSort2", arr2);
        }
    }

    @Test
    public void testRangeSort() {
        Integer[] arr = new Integer[]{1, 9, 8, 7, 6, 5, 4, 3, 2, 10};
        InsertionSort.sort(arr, 1, 8);
        for (Integer item : arr) {
            System.out.print(item + ",");
        }
    }

    @Test
    public void testSort2() {
        Integer[] arr = new Integer[]{9, 8, 7, 6, 5, 4, 3, 2};
        InsertionSort.sort2(arr);
        for (Integer item : arr) {
            System.out.print(item + ",");
        }
    }
}
